package com.ojoin.trade.common.web.dao.impl;

import com.ojoin.trade.common.exception.BusinessException;
import com.ojoin.trade.common.exception.DaoException;
import com.ojoin.trade.common.utils.TimeUtils;
import com.ojoin.trade.common.web.dao.TbWeekEndDao;
import com.ojoin.trade.common.web.domain.TbWeekend;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 16-4-15
 * Time: 下午2:24
 * To change this template use File | Settings | File Templates.
 */
@Repository
public class TbWeekEndDaoImpl extends BaseDaoImpl<TbWeekend> implements TbWeekEndDao {
    @Override
    public TbWeekend queryWorkDayForWeekend(String date, String year) throws BusinessException {
    	if (StringUtils.isEmpty(date))
    		date= TimeUtils.getCurDate();
    	
    	if (StringUtils.isEmpty(year))
        	year=TimeUtils.getCurYear();
        String methodMap="selectDate";
        Map<String,Object> map=new HashMap<>() ;
        map.put("year",year);
        map.put("date",date);
        try{
            TbWeekend vo=this.sqlSessionTemplate.selectOne(methodMap,map);
            return vo;
        }catch (Exception e){
            throw new DaoException(String.format("查询节假日出错！语句：%s",
                    getSqlName(methodMap)), e);
        }

    }

}
